﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Collections;
namespace WindowsGame4
{
    public class AsteroidEmitter : ParticleEmitter
    {
        public AsteroidEmitter()
            : base()
        {
        }
        public override GameObject EmitParticle()
        {
            if (!HasPlanets())//&&GameManager.random.Next(5) == 4)
                return new Planet();
            return new Asteroid();
        }
        public bool HasPlanets()
        {
            foreach (GameObject p in particles)
                if (p is Planet)
                    return true;
            return false;
        }
        public override GameObject CustomizeParticle(GameObject p)
        {
            p = base.CustomizeParticle(p);
            Vector2 dir = p.pos - GameManager.player.pos;
            if (dir.Length() > 0)
                dir.Normalize();
            if (p is Planet)
            {
                p.scale = new Vector2(2, 2);
                p.vel = new Vector2();
                p.rotSpeed = 20;
                p.bBlocks = false;
                p.bMoves = false;
                p.pos = GameManager.player.pos + dir * (p.GetRadius() + 468);
                return p;
            }
            Asteroid a = (Asteroid)p;
            a.pos = GameManager.player.pos + dir * (a.GetRadius() + 468);
            a.moveSpeed = moveSpeed;
            a.SetScale();
            return a;
        }
    }
}
